<form class="area" style="padding-bottom:40px;">
    <dl class="optBox mt20">
        <dt class="opt"><label class="lb" for="">角色名称</label></dt>
        <dd class="opCon">
            <input type="text" name="name" id="name" class="txt" placeholder="请输入角色名称" value="{{role['name']}}">
            <p class="tip"></p>
        </dd>
    </dl>
    <dl class="optBox mt20">
        <dt class="opt"><label class="lb" for="">角色头像</label></dt>
        <dd class="opCon" id="ssq">
            <select name="imgId" id='imgId' style="width: 150px" class="select2" data="{{role['imgId']}}" >
                <option value="0">无</option>
                {% for material in imgList %}
                <option value="{{material['id']}}">{{material['name']}}</option>
                {% endfor %}
            </select>
        </dd>
    </dl>
    <p class="mt20 tc"><input type="button"  value="提交"   id="edit"  /> <input type="button"  value="返回"  class="btn-back"  /></p>
</form>



<input type="hidden" id="ajaxEdit" value="{{url("scenario/ajaxRoleEdit")}}">

<input type="hidden" id="id" value="{{role['id']}}">
 
<script type="text/javascript">
$(window).load(function () {

    $('#edit').click(function () {
        var json = {
            "id": $('#id').val(),
            "name": $('#name').val(),
            "imgId": $('#imgId').val(),
        };
        var successFunction = function (data) {
            if (data.status == 200) {
                alert("修改成功");
                window.location.href = "{{url('scenario/scenarioRole')}}?id={{role['scenarioId']}}";
            } else if (data.status == -1) {
                alert(data.info);
            }
        };
        var errorFunction = function () {

        };
        $.ajax({
            url: $("#ajaxEdit").val(),
            data: json,
            type: "post",
            error: errorFunction,
            success: successFunction
        });
    });




});



</script>

